package com.lyf.scm.plan.api.controller;

import com.lyf.scm.plan.domain.service.BigDataEsRequirementService;
import com.lyf.scm.plan.domain.service.SalesPlanDirectlySynEsService;
import com.rome.arch.core.clientobject.Response;
import com.rome.arch.util.controller.RomeController;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;

/**
 * es解决方案---需求计划
 *
 * @author wangchlei
 * @date 2020/10/20
 */
@Slf4j
@RomeController
@RequestMapping("/api/v1/bigData/requirement")
public class BigDataEsRequirementController {
    @Resource
    private BigDataEsRequirementService bigDataEsRequirementService;
    @Resource
    private SalesPlanDirectlySynEsService salesPlanDirectlySynEsService;
    /**
     * job
     *
     * @param
     * @return {@link Response}
     **/
    @PostMapping("/job")
    public Response handleApiDispatcher() {
        bigDataEsRequirementService.handleApiDispatcher();
        return Response.builderSuccess(null);
    }

    @PostMapping("/trigger")
    public Response triggerJob() {
        bigDataEsRequirementService.triggerJob();
        return Response.builderSuccess(null);
    }

    @PostMapping("/directly/synData")
    public Response synDirectlyData(@RequestParam("specifiedDate") String specifiedDate){
        salesPlanDirectlySynEsService.transData2SalesPlanEs(specifiedDate);
        return Response.builderSuccess(null);
    }

    @GetMapping("/stopDirectlyTask")
    public Response stopDirectlyTask(){
        salesPlanDirectlySynEsService.stopTask();
        return Response.builderSuccess(null);
    }
}
